﻿using System.Data.Entity.ModelConfiguration;
using eCommerce.Core.Domain.Products;

namespace eCommerce.Data.Mapping.Products
{
    public class ProductMapping : EntityTypeConfiguration<Product>
    {
        public ProductMapping()
        {
            this.ToTable("Products");
            this.HasKey(p => p.Id);
            this.Property(p => p.ProductName).IsRequired().HasMaxLength(400);
      
            this.HasRequired(s => s.Shop).WithMany(c => c.Products)
                .HasForeignKey(o => o.ShopId).WillCascadeOnDelete(false);
        }
    }
}